﻿CREATE view [dbo].[vw_SumData] as 

select a.attnNum ,b.cardNum ,b.userNum, c.apptSum ,d.paySum ,e.prepaySum

from 

( select  COUNT(*) as attnNum from [User] where UnsubscribeDt is null ) a
,
( select count(distinct cardno) as cardNum,COUNT(distinct OpenId) as userNum  from HospCard where DeleteStatus = 0 ) b
,
( select SUM(SumFee) as apptSum from ApptOrder where PayState = 1 and SumFee > 0) c
,
( select SUM(PrescMoney) - SUM(coalesce(YibaoMoney,0)) as paySum from BillOrder where PayState = 1 and PrescMoney > 0 ) d
,
( select sum(prepayMoney) as prepaySum from inpatientprepayorder where paystate = 1 ) e
